Various aspects of the present invention relate generally to the utilization of a memory heap, and more particularly, to the efficient organization and utilization of small and large object areas within a memory heap.
A Java Virtual Machine (JVM) reserves a slot of memory, referred to as a Java heap, to temporarily store java application created objects. The Java Virtual Machine determines the size of the Java heap based in part, upon two user-controllable parameters, including an Initial Heap Size parameter and a Maximum Heap Size parameter.
At start up, the Java Virtual Machine reserves a single, contiguous chunk of memory for the Java heap from the operating system, based upon the Maximum Heap Size parameter. However, the Java Virtual Machine starts using the Java heap for object allocations as if it were configured using the Initial Heap Size parameter. In use, applications allocate objects into the Java heap. As the number of allocated objects increase, the Java heap can grow up to the maximum heap size established by the Maximum Heap Size parameter, to accommodate the allocated objects.
During use, objects in the heap may eventually become unreferenced. In this regard, a process referred to as a Garbage Collector (GC) occasionally cleans the Java heap by finding and removing unreferenced objects from the heap. The Garbage Collector thus frees memory, which allows applications to continue to allocate objects within the heap. Also, over time, the Java heap becomes fragmented. Fragmentation can cause the Garbage Collector to perform cleanup operations more frequently relative to an un-fragmented heap. Moreover, the cost of allocating a new object to the Java heap can potentially increase during use, e.g., due to the time required to locate a free memory chunk large enough to store the new object within a fragmented heap compared to a relatively un-fragmented heap. As such, the Garbage Collector may eventually be required to perform compaction of the Java heap. Compaction is an expensive process to perform due to the time required to move objects and update references to objects within the heap. Compaction and frequent cleanup can thus degrade performance of the Java Virtual Machine.